# 读文件并打上标签 O,然后手动改标签
def operate(oldfilepath, newfilepath):
    oldtext = open(oldfilepath, encoding='utf-8')
    lines = oldtext.readlines()
    oldtext.close()
    for line in lines:
        rs = line.rstrip('\n')  # 去除每行最后的换行符
        if rs is None or rs=='':
            newfile.write(rs + "\n")
        else:
            newres = rs + " " + str('O')
            newfile = open(newfilepath, 'a', encoding='utf-8')
            newfile.write(newres + "\n")
    newfile.close()


if __name__ == '__main__':
    oldfilepath = r"F:\develop_code\py_code\demo\label_data\raw.txt"
    newfilepath = r"F:\develop_code\py_code\demo\label_data\processed.txt"
    operate(oldfilepath, newfilepath)
